package com.simba.server.commands.impl.update;

import com.simba.common.command.ICommand;
import com.simba.common.database.DbOperator;
import com.simba.server.components.data.BoxInfo;

public class RenewBoxPackCmd implements ICommand
{
	public static final String NAME = "RenewBoxPackCmd";
	private final BoxInfo boxinfo;
	private final String sql = "update tt_slot_pack_info set boxType=?, uploadFlag=?,uploadNum=?,roadSlot=?,cmdPrintTemplate=?  where boxCode=?;";

	public RenewBoxPackCmd(BoxInfo boxinfo)
	{
		this.boxinfo = boxinfo;
	}

	@Override
	public String getName()
	{
		return RenewBoxPackCmd.NAME;
	}

	@Override
	public Boolean run(Object params)
	{
		Boolean ret = false;

		if (!(params instanceof DbOperator))
		{
			return ret;
		}

		try
		{
			DbOperator dbOperator = (DbOperator) params;

			dbOperator.prepareStatement(this.sql);

			dbOperator.setString(1, this.boxinfo.getBoxType());
			dbOperator.setInt(2, this.boxinfo.getUploadFlag());
			dbOperator.setInt(3, this.boxinfo.getUploadNum());
			dbOperator.setString(4, this.boxinfo.getRoadSlot());
			dbOperator.setString(5, this.boxinfo.getTemplate());
			dbOperator.setString(6, this.boxinfo.getBoxCode());


			int rs = dbOperator.executeUpdate();
			if (rs > 0)
			{
				ret = true;
			}
			else
			{
				ret = false;
			}
		}
		catch (Exception ex)
		{
			ret = false;
		}

		return ret;
	}

}
